package com.cyjt.operation.ui;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.cyjt.operation.R;
import com.cyjt.operation.base.AppContext;
import com.cyjt.operation.view.ActionBarLayout;

/**
 * 个人资料的Activity
 * 
 * @author LTP
 *
 */
public class PersonalDataActivity extends Activity {
	/** 姓名 */
	private TextView textView_name;
	/** 登录名 */
	private TextView textView_nfcCode;
	/** 性别 */
	private TextView textView_sex;
	/** 手机号 */
	private TextView textView_mobile;
	/** 注册时间 */
	private TextView textView_createAt;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_personal_data);
		initView();
		showText();
	}

	/**
	 * 控件初始化
	 */
	private void initView() {
		ActionBarLayout.setTitle("个人资料");
		textView_name = (TextView) findViewById(R.id.textView_name);
		textView_nfcCode = (TextView) findViewById(R.id.textView_nfcCode);
		textView_sex = (TextView) findViewById(R.id.textView_sex);
		textView_mobile = (TextView) findViewById(R.id.textView_mobile);
		textView_createAt = (TextView) findViewById(R.id.textView_createAt);
	}

	/**
	 * 显示文本信息(包括姓名、登录名、性别、手机号码以及注册时间)
	 */
	private void showText() {
		textView_name.setText(AppContext.getInstance().getUser().getName());
		textView_nfcCode.setText(AppContext.getInstance().getUser()
				.getNfcCode());
		if (AppContext.getInstance().getUser().getSex() == 1) {
			textView_sex.setText("男");
		} else {
			textView_sex.setText("女");
		}
		textView_mobile.setText(AppContext.getInstance().getUser().getMobile());
		textView_createAt.setText(AppContext.getInstance().getUser()
				.getCreateAt().substring(0, 10));
	}
}
